<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #div1 {
            width: 200px;
            height: 200px;
            background-color: #f00;
            position: relative;
        }
    </style>
    <script src="https://cdn.staticfile.org/jquery/2.0.0/jquery.min.js"></script>
    <script>
        $(document).ready(function () {
            $("#click").click(function () {
                $("#div1").animate({
                    left: "+=50px"
                }, 1000);
                $("#div1").animate({
                    left: "-=50px"
                }, 1000);
                $("#div1").animate({
                    left: "50px"
                }, 1000);
                $("#div1").animate({
                    left: "+=50px"
                });
            });
        });
    </script>


</head>

<body>
    <div id="div1">
        <h1>Hello World!</h1>
        <p>This is a paragraph.</p>
    </div>
    <br />
    <button id="click">开始动画</button>
</body>

</html>